home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Scheduling / Cassandra / Source / DayWindow.m < prev    next >
Encoding:
Text File  |  1991-08-18  |  4.0 KB  |  212 lines

  1. //
  2. // DayWindow.m
  3. // Copyright (c) 1991 by Jiro Nakamura 
  4. // All rights reserved
  5. //
  6. //    by Jiro Nakamura (jiro@shaman.com)
  7. //
  8. // RCS Information
  9. // Revision Number->    $Revision: 1.3 $
  10. // Last Revised->    $Date: 91/02/17 22:03:21 $
  11. //
  12. static char rcsid[] = "$Id: WeekWindow.m,v 1.3 91/02/17 22:03:21 jiro Exp Locker: jiro $";
  13.  
  14. #import "Global.h"
  15. #import "DayText.h"
  16. #import "Event.h"
  17. #import "cass.h"    // for TODAYICON
  18. #import "calendar.h"    // for ascMyDate()
  19. #import "Cassandra.h"        // For NXApp 
  20. #import <appkit/ScrollView.h>
  21. #import <appkit/TextField.h>
  22. #import <appkit/PopUpList.h>
  23. #import <appkit/Matrix.h>
  24. #import "DayWindow.h"
  25.  
  26. #import <sys/file.h>
  27. #import <libc.h>
  28. #import <strings.h>
  29.  
  30.  
  31.  
  32. // The minimum dimensions of the day window
  33. #define MIN_WIDTH        870.0
  34. #define MIN_HEIGHT        100.0
  35.  
  36.  
  37. @implementation DayWindow
  38.  
  39. - open:sender
  40. {
  41.     static alreadyInited = FALSE;
  42.     NXRect tmpFrame;
  43.     
  44.     if( !alreadyInited)
  45.         {
  46.         alreadyInited = TRUE;
  47. //        [self placeWindow: [[NXApp global] dayFrame]];
  48.         today = *timeNow();
  49.         today.tm_hour = today.tm_min = today.tm_sec = 0;
  50.         fixTmStructure( &today);
  51.         
  52.         #ifdef DEBUG
  53.             fprintf(stderr,"Today is: %s", 
  54.                 ascMyDate(&today));
  55.         #endif
  56.         priorityCutOff = [[NXApp global] lowPriority];
  57.         [self    setDelegate: self];
  58.     
  59.         [[eventsScroll docView] getFrame: &tmpFrame];
  60.         eventsText = [[DayText alloc] initFrame:
  61.             &tmpFrame];    
  62.         [eventsScroll setDocView: eventsText];
  63.         [eventsText setMonoFont: FALSE];
  64.         [eventsText setEditable: YES];
  65.         [eventsText setBackgroundGray: NX_WHITE];
  66.  
  67. //        [self setMiniwindowIcon:     DAYICON];
  68.         
  69.         viewPopUp =         [PopUpList new];
  70.         [viewPopUp    addItem:    "View All"];
  71.         [viewPopUp    addItem:    "View Mid~High"];
  72.         [viewPopUp    addItem:    "View Only High"];
  73.         [[viewPopUp itemList] selectCellAt:1:0];
  74.         NXAttachPopUpList(viewPopUpButton, viewPopUp);
  75.         }
  76.     [self    makeKeyAndOrderFront: self];
  77.     [self    update];    // this will cause an update
  78.     return self;
  79. }
  80.  
  81. - save
  82. {
  83.     // This window shouldn't save itself. 
  84.     return nil;
  85. }
  86.  
  87. - close
  88. {
  89. //    [[NXApp global]    saveThisWindowPosition:    DEFAULTDAYFRAME : self];
  90.     [super close];
  91.     miniaturized = FALSE;
  92.     return self;
  93. }
  94.  
  95. - update
  96. {
  97.     static char temp[20];
  98.     extern const char *shortMonths[12], *shortWeekDays[7];
  99.     
  100.     
  101.     if( miniaturized || ![self isVisible])
  102.         return self;
  103.  
  104.     sprintf(temp, "%s %s %2d, %d", 
  105.         shortWeekDays[today.tm_wday],
  106.         shortMonths[today.tm_mon], 
  107.         today.tm_mday,today.tm_year + 1900);
  108.     [dayTextField setStringValue:    temp];    
  109.  
  110.     [eventsText setDate: &today andPriority: priorityCutOff];
  111.     [eventsText updateText];
  112.     
  113.     
  114.     
  115.     
  116.     return self;
  117. }
  118.  
  119. - dayBefore:sender
  120. {        
  121.     today.tm_mday -= 1;
  122.     [self update];
  123.     return self;
  124. }
  125.  
  126. - dayAfter:sender
  127. {
  128.     today.tm_mday += 1;
  129.     [self update];
  130.     return self;
  131. }
  132.  
  133. - dayNow:sender
  134. {
  135.     today = *timeNow();
  136.     today.tm_hour = today.tm_min = today.tm_sec = 0;
  137.     fixTmStructure( &today);
  138.     [self update];
  139.     return self;
  140. }
  141.  
  142.  
  143. - viewPopUpChanged:sender
  144. {    
  145.     switch( [[viewPopUp itemList] selectedRow])
  146.         {
  147.         case 2:
  148.             priorityCutOff = [[NXApp global] highPriority];
  149.             break;
  150.         case 1:
  151.             priorityCutOff = [[NXApp global] lowPriority];
  152.             break;
  153.         case 0:
  154.         default:
  155.             priorityCutOff = 0;
  156.             break;
  157.         }
  158.     #ifdef DEBUG
  159.         fprintf(stderr, "Priority changed to %d.... (tag = %d)\n",
  160.              priorityCutOff, [[viewPopUp itemList] selectedRow]);
  161.     #endif
  162.     [self update];
  163.     return self;
  164. }
  165.  
  166. - windowDidMiniaturize: sender
  167. {
  168.     #ifdef DEBUG
  169.         fprintf(stderr,"Today did miniaturize\n");
  170.     #endif
  171.  
  172.     miniaturized = TRUE;
  173.     return self;
  174. }
  175.  
  176. - windowDidDeminiaturize: sender
  177. {
  178.     #ifdef DEBUG
  179.         fprintf(stderr,"Today did deminiaturize\n");
  180.     #endif
  181.  
  182.     miniaturized = FALSE;
  183.     [self update];
  184.     return self;
  185. }
  186.  
  187. - defaultsDidChange: sender
  188. {
  189.     return [eventsText defaultsDidChange: sender];
  190. }
  191.  
  192.  
  193.  
  194. - windowWillResize: (id) sender toSize: (NXSize *) size
  195. {
  196.     #ifdef DEBUG
  197.         fprintf(stderr,"Window would have resized to %f x %f.\n", 
  198.             size->width, size->height);
  199.     #endif
  200.     
  201.     size->width = MIN_WIDTH;    // can't change the width, ever
  202.     if( size->height < MIN_HEIGHT)
  203.         size->height = MIN_HEIGHT;
  204.         
  205.     #ifdef DEBUG
  206.         fprintf(stderr,"Window will resize to %f x %f.\n", 
  207.             size->width, size->height);
  208.     #endif
  209.     return self;
  210. }
  211. @end
  212.